

import junit.framework.*;
import reittiopas.*;
	
import java.util.Vector;


public class TestRouteServiceAndXMLParser extends TestCase {
	private RouteService rs;
	
	public void setUp() { 
		rs = new RouteService();
	}
	
	public void testShouldUseTheTimeArgument() {
		String parameterTime = "1215";
		String date = "20100501";
		Location startL = rs.getLocation("Maapadontie 3");
		Location destL = rs.getLocation("Keskusta");
		
		Vector routes = rs.getRoutes(startL, destL, parameterTime, date, true);  //isStartTime
		Route r = (Route)routes.firstElement();
		String departureTime = r.getStartLocation().getDepartureTime();
		departureTime = departureTime.substring(0,2) + departureTime.substring(3,5);
		assertTrue(Integer.parseInt(departureTime) > Integer.parseInt(parameterTime));
		
		routes = rs.getRoutes(startL, destL, parameterTime,date,  false);  //not isStartTime
		r = (Route)routes.firstElement();
		departureTime = r.getStartLocation().getDepartureTime();
		departureTime = departureTime.substring(0,2) + departureTime.substring(3,5);
		assertTrue(Integer.parseInt(departureTime) < Integer.parseInt(parameterTime));
	}


}
